Public Class f_DCTDMLSelection
    Dim objhdlr As New Cls_DCTDevHdlr
    Dim strConString As String = "data source=.;initial catalog=" & f_DCTDevPreparation.f & ";persist security info=False;user id=realm;password=friend;packet size=4096"
    Private Sub f_DCTtableselection_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ddlDMLScen.SelectedIndex = 0
        loadgrid()
    End Sub

    Private Sub ddlDMLScen_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlDMLScen.SelectedIndexChanged
        If ddlDMLScen.SelectedIndex > 0 Then
            lblScenSelected.Text = ddlDMLScen.Text + " Scenario"
        Else
            lblScenSelected.Text = ""
        End If
        loadgrid()
    End Sub
    Private Sub loadgrid()
        Dim ds As New DataSet
        Dim i As Integer
        ds = objhdlr.GetDCTtableList(strConString)
        dgdNormalDML.DataSource = ds.Tables(0).DefaultView
        dgdNormalDML.Columns("name").DisplayIndex = 0
        dgdNormalDML.Columns("DMLStatusI").DisplayIndex = 1
        dgdNormalDML.Columns("DMLStatusU").DisplayIndex = 2
        dgdNormalDML.Columns("DMLStatusD").DisplayIndex = 3
        dgdNormalDML.Columns("tblid").Visible = False
        dgdNormalDML.AutoResizeColumns()
        If ddlDMLScen.SelectedIndex = 3 Then
            i = dgdNormalDML.Rows.Count
            For i = 0 To i - 1
                dgdNormalDML.Rows(i).Cells(1).Value = 0
                dgdNormalDML.Rows(i).Cells(1).ReadOnly = True
            Next
        Else
            i = dgdNormalDML.Rows.Count
            For i = 0 To i - 1
                dgdNormalDML.Rows(i).Cells(1).ReadOnly = False
            Next
        End If
    End Sub
    Private Sub btnsetDML_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsetDML.Click
        Dim objparent As New Cls_DCTDMLSelection
        Dim objchild As New Str_DCTDMLSelection
        Dim alDMLstatus As New ArrayList
        Dim strConString As String = "data source=.;initial catalog=" & f_DCTDevPreparation.f & ";persist security info=False;user id=realm;password=friend;packet size=4096"
        If ddlDMLScen.SelectedIndex > 0 Then
            Dim i As Integer
            i = dgdNormalDML.Rows.Count
            For i = 0 To i - 1
                objchild.DMLScenario = ddlDMLScen.SelectedIndex
                objchild.tblID = dgdNormalDML.Rows(i).Cells(4).Value
                objchild.Mode = "NA"
                If dgdNormalDML.Rows(i).Cells(0).Value = 1 Then
                    objchild.checkedI = 1
                    objchild.Mode = "U"
                Else
                    objchild.checkedI = 0
                End If
                If dgdNormalDML.Rows(i).Cells(1).Value = 1 Then
                    objchild.checkedU = 1
                    objchild.Mode = "U"
                Else
                    objchild.checkedU = 0
                End If
                If dgdNormalDML.Rows(i).Cells(2).Value = 1 Then
                    objchild.checkedD = 1
                    objchild.Mode = "U"
                Else
                    objchild.checkedD = 0
                End If
                alDMLstatus.Add(objchild)
            Next
            objparent.DMLStatus = alDMLstatus
            objhdlr.UpdateDMLData(objparent, strConString)
            MessageBox.Show("Tables updated with DML status successfully")
            loadgrid()
        Else
            MessageBox.Show("Please select DML Scenario")
        End If
    End Sub

    Private Sub btnDone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDone.Click
        Dim f1 As New f_DCTTablePKSelection
        'f1.Show()
        Me.Hide()
    End Sub
End Class